package cn.forward.controller.app;

import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaIgnore;
import cn.forward.param.AppLoginParam;
import cn.forward.pojo.vo.LoginVo;
import cn.forward.result.R;
import cn.forward.service.ILoginService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
@Tag(name = "注册到登录表",description = "注册到登录表")
@RequestMapping("/app/login")
@RestController
public class AppLoginController {

    @Autowired
    private ILoginService loginService;

    @PostMapping
    @Operation( summary= "注册到登录表",description = "注册到登录表feign调用")
    @Parameter(name = "Login",description = "初始化登录表",required = true)
    @SaIgnore
    public R<Void> sava(@RequestBody @Valid AppLoginParam appLoginParam){
        loginService.appSave(appLoginParam);
        return R.success();
    }


    @Operation( summary= "登录实现",description = "登录实现接口")
    @Parameter(name = "openIdCode",description = "code获取openId登录",required = true)
    @Parameter(name = "type",description = "管理端0，司机端1，乘客端2",required = true)
    @PostMapping(value = "/wxLogin/{openIdCode}/{type}")
//    @SaCheckPermission("APP:LOGIN")
    @SaIgnore
    public R<LoginVo> wxLogin(@PathVariable("openIdCode")String openIdCode, @PathVariable("type") String type){

        return R.success(loginService.wxLogin(openIdCode,type));
    }

}
